<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9"/>
<title>MSC for Windows&amp;Linux API: qivw.h 文件参考</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">MSC for Windows&amp;Linux API
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.9 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>首页</span></a></li>
      <li class="current"><a href="files.html"><span>文件</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="搜索" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>文件列表</span></a></li>
      <li><a href="globals.html"><span>文件成员</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#func-members">函数</a>  </div>
  <div class="headertitle">
<div class="title">qivw.h 文件参考</div>  </div>
</div><!--header-->
<div class="contents">

<p>iFLY Speech Voice Wakeup Header File  
<a href="#details">更多...</a></p>

<p><a href="qivw_8h_source.html">浏览源代码.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
函数</h2></td></tr>
<tr class="memitem:a68ca9b338bb41fd2d074fc3777bfd3b1"><td class="memItemLeft" align="right" valign="top">const char *MSPAPI&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qivw_8h.html#a68ca9b338bb41fd2d074fc3777bfd3b1">QIVWSessionBegin</a> (const char *grammarList, const char *params, int *errorCode)</td></tr>
<tr class="memdesc:a68ca9b338bb41fd2d074fc3777bfd3b1"><td class="mdescLeft">&#160;</td><td class="mdescRight">开始唤醒功能，并在参数中指定唤醒(唤醒+识别时)用到的语法列表，本次唤醒所用的参数等。  <a href="#a68ca9b338bb41fd2d074fc3777bfd3b1">更多...</a><br /></td></tr>
<tr class="separator:a68ca9b338bb41fd2d074fc3777bfd3b1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6f5d689d119ed46b4f6b47b2a8c43718"><td class="memItemLeft" align="right" valign="top">int MSPAPI&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qivw_8h.html#a6f5d689d119ed46b4f6b47b2a8c43718">QIVWSessionEnd</a> (const char *sessionID, const char *hints)</td></tr>
<tr class="memdesc:a6f5d689d119ed46b4f6b47b2a8c43718"><td class="mdescLeft">&#160;</td><td class="mdescRight">结束本次语音唤醒。  <a href="#a6f5d689d119ed46b4f6b47b2a8c43718">更多...</a><br /></td></tr>
<tr class="separator:a6f5d689d119ed46b4f6b47b2a8c43718"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6078304711af5be74cf4767b835cca96"><td class="memItemLeft" align="right" valign="top">int MSPAPI&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qivw_8h.html#a6078304711af5be74cf4767b835cca96">QIVWAudioWrite</a> (const char *sessionID, const void *audioData, unsigned int audioLen, int audioStatus)</td></tr>
<tr class="memdesc:a6078304711af5be74cf4767b835cca96"><td class="mdescLeft">&#160;</td><td class="mdescRight">写入本次唤醒的音频，本接口需要反复调用直到音频写完为止。  <a href="#a6078304711af5be74cf4767b835cca96">更多...</a><br /></td></tr>
<tr class="separator:a6078304711af5be74cf4767b835cca96"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae00c19a49e0933c2d10d9cbc1ebccdf3"><td class="memItemLeft" align="right" valign="top">int MSPAPI&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qivw_8h.html#ae00c19a49e0933c2d10d9cbc1ebccdf3">QIVWRegisterNotify</a> (const char *sessionID, ivw_ntf_handler msgProcCb, void *userData)</td></tr>
<tr class="memdesc:ae00c19a49e0933c2d10d9cbc1ebccdf3"><td class="mdescLeft">&#160;</td><td class="mdescRight">注册回调。  <a href="#ae00c19a49e0933c2d10d9cbc1ebccdf3">更多...</a><br /></td></tr>
<tr class="separator:ae00c19a49e0933c2d10d9cbc1ebccdf3"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<div class="textblock"><p>iFLY Speech Voice Wakeup Header File </p>
<p>This file contains the quick application programming interface (API) declarations of IVW. Developer can include this file in your project to build applications. For more information, please read the developer guide.</p>
<p>Use of this software is subject to certain restrictions and limitations set forth in a license agreement entered into between iFLYTEK, Co,LTD. and the licensee of this software. Please refer to the license agreement for license use rights and restrictions.</p>
<p>Copyright (C) 1999 - 2015 by iFLYTEK, Co,LTD. All rights reserved.</p>
<dl class="section author"><dt>作者</dt><dd>MSC </dd></dl>
<dl class="section version"><dt>版本</dt><dd>5.0 </dd></dl>
<dl class="section date"><dt>日期</dt><dd>2015/03/19</dd></dl>
<dl class="section see"><dt>参见</dt><dd></dd></dl>
<p><b>History:</b><br />
 </p><table class="doxtable">
<tr>
<th>Version </th><th>Date </th><th>Author </th><th>Notes </th></tr>
<tr>
<td>5.0 </td><td>2015/03/19 </td><td>MSC </td><td>Create this file </td></tr>
</table>
</div><h2 class="groupheader">函数说明</h2>
<a class="anchor" id="a68ca9b338bb41fd2d074fc3777bfd3b1"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const char* MSPAPI QIVWSessionBegin </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>grammarList</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>params</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>errorCode</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>开始唤醒功能，并在参数中指定唤醒(唤醒+识别时)用到的语法列表，本次唤醒所用的参数等。 </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">grammarList[in]</td><td>bnf格式的语法，一个引擎内置语法列表。可以同时指定多个语法，不同的语法之间以","隔开。进行语音唤醒时不需要语法，此参数设定为NULL 或空串即可；进行语 音唤醒+识别时则需要语法，语法可以在此参数中指定。 </td></tr>
    <tr><td class="paramname">params[in]</td><td>参见下表: <table class="doxtable">
<tr>
<th>参数 </th><th>参数说明 </th><th>是否必要  </th></tr>
<tr>
<td>sst </td><td>业务类型。唤醒业务类型,可以设置如下参数：<br />
wakeup：语音唤醒(默认)<br />
oneshot：唤醒加识别</td><td>是  </td></tr>
<tr>
<td>ivw_threshold </td><td>唤醒词门限。<br />
设置格式如下：<br />
id0:xx;id1:xx;….。<br />
示例：0:15;1:-10表示设置第一个唤醒词的门限值为15，第二个唤醒的门限值是-10，门限值越低越容易唤醒成功。<br />
普通唤醒一般为-20，强唤醒一般为15<br />
注意：设置的门限值的个数多于唤醒资源中唤醒词的个数时会报错。 </td><td>否  </td></tr>
<tr>
<td>ivw_shot_word </td><td>音频是否包含唤醒词。<br />
用于唤醒加识别时场景，将音频送入识别引擎时是否包含唤醒词音频：<br />
0：不包含，1：包含(默认) </td><td>否  </td></tr>
</table>
</td></tr>
    <tr><td class="paramname">errorCode[out]</td><td>函数调用成功则其值为MSP_SUCCESS，否则返回错误代码，<a href="http://open.voicecloud.cn/index.php/default/doccenter/doccenterInner?itemTitle=ZmFx&amp;anchor=Y29udGl0bGU2Ng==" target="_blank">详见错误码列表</a>。 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>函数调用成功返回字符串格式的sessionID，失败返回NULL。sessionID是本次唤醒的句柄。 </dd></dl>
<dl class="section remark"><dt>备注</dt><dd>参数只在当次唤醒中生效。</dd></dl>
<dl class="section see"><dt>参见</dt><dd><pre class="fragment">const char* params = "ivw_threshold=0:-20, ivw_res_path =fo|res/ivw/wakeupresource.jet";
int ret = 0;
const char* sessionID = QIVWSessionBegin( NULL, params, &amp;ret );
if( MSP_SUCCESS != ret )
{
    printf( "QIVWSessionBegin failed, error code is: %d", ret );
}
.</pre> </dd></dl>

</div>
</div>
<a class="anchor" id="a6f5d689d119ed46b4f6b47b2a8c43718"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int MSPAPI QIVWSessionEnd </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>sessionID</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>hints</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>结束本次语音唤醒。 </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">sessionID[in]</td><td>由QIVWSessionBegin返回的句柄。 </td></tr>
    <tr><td class="paramname">hints[in]</td><td>结束本次语音唤醒的原因描述，为用户自定义内容。 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>函数调用成功则其值为MSP_SUCCESS，否则返回错误代码，<a href="http://open.voicecloud.cn/index.php/default/doccenter/doccenterInner?itemTitle=ZmFx&amp;anchor=Y29udGl0bGU2Ng==" target="_blank">详见错误码列表</a>。 </dd></dl>
<dl class="section remark"><dt>备注</dt><dd>本接口和QIVWSessionBegin 对应，用来本次语音唤醒。调用此接口后，该句柄对应的相关资源（参数、语法、音频、实例等）都会被释放，用户不应再使用该句柄。</dd></dl>
<dl class="section see"><dt>参见</dt><dd><pre class="fragment">int ret = QIVWSessionEnd ( sessionID, "normal end" );
if( MSP_SUCCESS != ret )
{
    printf( "QIVWSessionEnd failed, error code is: %d", ret );
}
.</pre> </dd></dl>

</div>
</div>
<a class="anchor" id="a6078304711af5be74cf4767b835cca96"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int MSPAPI QIVWAudioWrite </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>sessionID</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>audioData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>audioLen</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>audioStatus</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>写入本次唤醒的音频，本接口需要反复调用直到音频写完为止。 </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">sessionID[in]</td><td>由QIVWSessionBegin返回的句柄。 </td></tr>
    <tr><td class="paramname">audioData[in]</td><td>音频数据缓冲区起始地址。 </td></tr>
    <tr><td class="paramname">audioLen[in]</td><td>音频数据长度，单位字节。 </td></tr>
    <tr><td class="paramname">audioStatus[in]</td><td>用来告知MSC音频发送是否完成，典型值如下： <table class="doxtable">
<tr>
<th>枚举常量 </th><th>简介  </th></tr>
<tr>
<td>MSP_AUDIO_SAMPLE_FIRST = 1 </td><td>第一块音频  </td></tr>
<tr>
<td>MSP_AUDIO_SAMPLE_CONTINUE = 2 </td><td>还有后继音频  </td></tr>
<tr>
<td>MSP_AUDIO_SAMPLE_LAST = 4 </td><td>最后一块音频  </td></tr>
</table>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>函数调用成功则其值为MSP_SUCCESS，否则返回错误代码，<a href="http://open.voicecloud.cn/index.php/default/doccenter/doccenterInner?itemTitle=ZmFx&amp;anchor=Y29udGl0bGU2Ng==" target="_blank">详见错误码列表</a>。 </dd></dl>
<dl class="section remark"><dt>备注</dt><dd>调用本接口时，推荐用户在写入音频时采取"边录边写"的方式，即每隔一小段时间将采集到的音频通过本接口写入MSC。</dd></dl>
<dl class="section see"><dt>参见</dt><dd><pre class="fragment">char audio_data[ 5120 ] ={'\0'};
unsigned int audio_len = 0;
int audio_status = 2;
int ret = 0;
while(MSP_AUDIO_SAMPLE_LAST != audio_status )
{
    // 读取音频到缓冲区audio_data 中，设置音频长度audio_len，音频状态audio_status。
    ret = QIVWAudioWrite( sessionID, audio_data, audio_len, audio_status);
    if( MSP_SUCCESS ! = ret )
    {
        printf( "QIVWAudioWrite failed, error code is: %d", ret );
        break;
    }
}
.</pre> </dd></dl>

</div>
</div>
<a class="anchor" id="ae00c19a49e0933c2d10d9cbc1ebccdf3"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int MSPAPI QIVWRegisterNotify </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>sessionID</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">ivw_ntf_handler&#160;</td>
          <td class="paramname"><em>msgProcCb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>userData</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>注册回调。 </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">sessionID[in]</td><td>由QIVWSessionBegin返回的句柄。 </td></tr>
    <tr><td class="paramname">msgProcCb[in]</td><td>注册通知的回调函数，唤醒结果将在此注册回调中返回。格式为：typedef int( *ivw_ntf_handler)( const char *sessionID, int msg,int param1, int param2, const void *info, void *userData );参数说明: <table class="doxtable">
<tr>
<th>参数 </th><th>说明  </th></tr>
<tr>
<td>sessionID </td><td>由QIVWSessionBegin返回的句柄。  </td></tr>
<tr>
<td>msg </td><td>MSP_IVW_MSG_WAKEUP=1 唤醒消息，在info中给出唤醒结果缓存首地址，param2 给出唤醒结果的长度。<br />
MSP_IVW_MSG_ERROR=2 出错通知消息，在param1 中给出错误码。<br />
MSP_IVW_MSG_ISR_RESULT=3 唤醒+识别结果消息，在info 中给出识别结果缓存首地址，param2 给出识别结果的长度。param1 中给出给出结果状态，结果状态值参见QISRAudioWrite接口中结果状态说明。<br />
MSP_IVW_MSG_ISR_EPS=4 唤醒+识别结果中vad 端点检测消息，param1 给出端点检测状态，状态值参见QISRAudioWrite接口中端点检测状态说明。  </td></tr>
<tr>
<td>param1 </td><td>参见msg 消息说明  </td></tr>
<tr>
<td>param2 </td><td>参见msg 消息说明  </td></tr>
<tr>
<td>info </td><td>参见msg 消息说明，主要内容包括sst,id,score,bos,eos等  </td></tr>
<tr>
<td>sst </td><td>本次业务标识：wakeup 表示语音唤醒；enroll 表示唤醒词训练（当前版本不支持）  </td></tr>
<tr>
<td>id </td><td>当前唤醒词的id  </td></tr>
<tr>
<td>score </td><td>当前唤醒得分  </td></tr>
<tr>
<td>bos </td><td>当前唤醒音频的前端点  </td></tr>
<tr>
<td>eos </td><td>当前唤醒音频的尾端点  </td></tr>
<tr>
<td>userData </td><td>用户数据  </td></tr>
</table>
</td></tr>
    <tr><td class="paramname">userData[in]</td><td>用户数据。 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>函数调用成功则其值为MSP_SUCCESS，否则返回错误代码，<a href="http://open.voicecloud.cn/index.php/default/doccenter/doccenterInner?itemTitle=ZmFx&amp;anchor=Y29udGl0bGU2Ng==" target="_blank">详见错误码列表</a>。 </dd></dl>
<dl class="section remark"><dt>备注</dt><dd>通过此函数注册回调函数到msc。如果唤醒成功，msc 调用回调函数通知唤醒成功息同时给出相应唤醒数据。如果出错，msc 调用回调函数给出错误信息。</dd></dl>
<dl class="section see"><dt>参见</dt><dd><pre class="fragment">int cb_ivw_msg_proc( const char *sessionID, int msg, int param1, int param2, const void *info,void *userData )
{
    if (MSP_IVW_MSG_ERROR == msg) //唤醒出错消息
    {
        printf("\n\nMSP_IVW_MSG_ERROR errCode = %d\n\n", param1);
    }
    else if (MSP_IVW_MSG_WAKEUP == msg) //唤醒成功消息
    {
        printf("\n\nMSP_IVW_MSG_WAKEUP result = %s\n\n", info);
    }
    return 0;
}
err_code = QIVWRegisterNotify(sessionID, cb_ivw_msg_proc,NULL);
if (err_code != MSP_SUCCESS)
{
    printf("QIVWRegisterNotify failed! error code:%d\n",err_code);
}
.</pre> </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
生成于 2017年 五月 25日 星期四 19:20:45 , 为 MSC for Windows&amp;Linux API使用  &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.9
</small></address>
</body>
</html>
